package club.emergency.wechat.resource_study.search.consumer.controller;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.utils.JsonConvert;
import club.emergency.wechat.resource_study.search.consumer.service.ResourceStudySearchConsumer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create with IntelliJ IDEA
 * Project Name: business
 * Package Name: club.emergency.wechat.resource_study.search.consumer.controller
 * Date: 2018/12/21
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Api("资料学习搜索接口")
@RestController
@RequestMapping("/resource-study-search")
public class ResourceStudySearchController {

    private ResourceStudySearchConsumer resourceStudySearchConsumer;

    public ResourceStudySearchController(ResourceStudySearchConsumer resourceStudySearchConsumer) {
        this.resourceStudySearchConsumer = resourceStudySearchConsumer;
    }

    @ApiOperation("查询资料学习")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "resourceCategory", name = "资料种类", dataType = "string", paramType = "query"),
            @ApiImplicitParam(value = "pageNo", name = "当前页", dataType = "int", paramType = "query"),
            @ApiImplicitParam(value = "pageSize", name = "当前一页显示的数据总条数", dataType = "int", paramType = "query")
    })
    @PostMapping("/flipList")
    public ResponseEntity flipList(
            @RequestParam(value = "resourceCategory", required = false) String resourceCategory,
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize
    ) {
        return new JsonConvert<ResponseEntity>().jsonDecode(resourceStudySearchConsumer.flipList(resourceCategory, pageNo, pageSize), ResponseEntity.class);
    }
}
